clear*
set maxvar 11000

global date _2025_10_28
cd "/Users/atri0032/Dropbox/World Bank/Temperature, poverty, and inequality/Estimations/"

******************************************************************************************
********************************** Table S4: Heterogeneity analysis by country characteristics
******************************************************************************************

***** Headcount poverty
use "${date}/_data/spid_for_analysis_v2.dta", clear

local controls ln_GDPppp Unempilo agri manuf popgr 

estimates clear
reghdfe poor215 c.temp##b1.rank_democracy rainfall_sum humid `controls', absorb(geo_code2_new year) cluster(geo_code2_new) keepsingle
	est store m1
reghdfe poor215 c.temp##i.country_equator rainfall_sum humid `controls', absorb(geo_code2_new year) cluster(geo_code2_new) keepsingle
	est store m2
reghdfe poor215 c.temp##c.indexagri rainfall_sum humid `controls', absorb(geo_code2_new year) cluster(geo_code2_new) keepsingle
	est store m3
reghdfe poor215 c.temp##c.indexmanu rainfall_sum humid `controls', absorb(geo_code2_new year) cluster(geo_code2_new) keepsingle
	est store m4
reghdfe poor215 c.temp##c.indextrade rainfall_sum humid `controls', absorb(geo_code2_new year) cluster(geo_code2_new) keepsingle
	est store m5

local opts ///
	cells(b(star fmt(3)) se(par fmt(3))) star(* 0.10 ** 0.05 *** 0.01) ///
	stats(N r2, fmt(0 3) ///
	label("Observations" "R-squared")) ///	
	eqlabels(none)  ///
	collabels(,none) varlabels(temp "Temperature" rainfall_ave "Rainfall" humid "Humidity") varwidth(25) ///
	title("Table s4 - Poverty")
	
esttab m*, `opts' 
esttab m* using "${date}/_tables/_tab_s4_poverty.csv", replace `opts' 


***** Inequality
use "${date}/_data/spid_for_analysis_v2.dta", clear

local controls ln_GDPppp Unempilo agri manuf popgr 

estimates clear
reghdfe gini c.temp##b1.rank_democracy rainfall_sum humid `controls', absorb(geo_code2_new year) cluster(geo_code2_new) keepsingle
	est store m1
reghdfe gini c.temp##i.country_equator rainfall_sum humid `controls',absorb(geo_code2_new year) cluster(geo_code2_new) keepsingle
	est store m2
reghdfe gini c.temp##c.indexagri rainfall_sum humid `controls', absorb(geo_code2_new year) cluster(geo_code2_new) keepsingle
	est store m3
reghdfe gini c.temp##c.indexmanu rainfall_sum humid `controls', absorb(geo_code2_new year) cluster(geo_code2_new) keepsingle
	est store m4
reghdfe gini c.temp##c.indextrade rainfall_sum humid `controls', absorb(geo_code2_new year) cluster(geo_code2_new) keepsingle
	est store m5

local opts ///
	cells(b(star fmt(3)) se(par fmt(3))) star(* 0.10 ** 0.05 *** 0.01) ///
	stats(N r2, fmt(0 3) ///
	label("Observations" "R-squared")) ///	
	eqlabels(none)  ///
	collabels(,none) varlabels(temp "Temperature" rainfall_ave "Rainfall" humid "Humidity") varwidth(25) ///
	title("Table s4 - Inequality")
	
esttab m*, `opts' 
esttab m* using "${date}/_tables/_tab_s4_inequality.csv", replace `opts' 
